$(document).ready(function()
{
	/**
	* 订单查询
	*/
	var ordersheet_button_submit=$('#Index_Search_Ordersheet_Button');	
	var ordersheet_button_reset=$('#Index_Search_Ordersheet_Reset');		
	var ordersheet_shipyardName=$('#Index_Search_Ordersheet_ShipyardName');
	var ordersheet_shipownerName=$('#Index_Search_Ordersheet_ShipownerName');
	var ordersheet_shiponwerNationality=$('#Index_Search_Ordersheet_ShipownerNationality');
	var ordersheet_shipType=$('#Index_Search_Ordersheet_Search_ShipType');
	var ordersheet_giveDatetime_Year=$('#Index_Search_Ordersheet_GiveDatetime_Year');
	var ordersheet_giveDatetime_Month=$('#Index_Search_Ordersheet_GiveDatetime_Month');

	ordersheet_button_reset.click(function()
	{
		ordersheet_shipyardName.val('');
		ordersheet_shipownerName.val('');
		ordersheet_shiponwerNationality.val('');
		ordersheet_shipType.val('');
		ordersheet_shipyardName.val('');
		ordersheet_giveDatetime_Year.val('');
		ordersheet_giveDatetime_Month.val('');		
		return false;
	});

	ordersheet_button_submit.click(function()
	{
		var isNotWrite=ordersheet_shipyardName.val()==''&&ordersheet_shipownerName.val()=='';
		{
			isNotWrite=isNotWrite&&ordersheet_shiponwerNationality.val()=='';
			isNotWrite=isNotWrite&&ordersheet_giveDatetime_Year.val()=='-1'&&ordersheet_giveDatetime_Month.val()=='-1';		
		}

		if(isNotWrite)
		{
			ordersheet_shipyardName.focus();
			return false;
		}

		var location='/exec.php?action=shipyard_ordersheet&type=search';
		{
			if(ordersheet_shipyardName.val()!=''){
				location=location+'&shipyardname='+encodeURI(ordersheet_shipyardName.val());
			}
			
			if(ordersheet_shipownerName.val()!=''){
				location=location+'&shipownername='+encodeURI(ordersheet_shipownerName.val());
			}
			
			if(ordersheet_shiponwerNationality.val()!=''){
				location=location+'&shiponwernationality='+encodeURI(ordersheet_shiponwerNationality.val());
			}		
			
			if(ordersheet_giveDatetime_Year.val()!='-1'){
				location=location+'&givedatetime_year='+ordersheet_giveDatetime_Year.val();
			}
			
			if(ordersheet_giveDatetime_Month.val()!='-1'){
				location=location+'&givedatetime_month='+ordersheet_giveDatetime_Month.val();
			}			
		}
		
		window.location=location;
		
		return false;
	});	
	

	/**
	* 船厂查询
	*/	
	$.initProv("#Index_Search_Shipyard_Province","#Index_Search_Shipyard_City");
	var shipyard_province=$('#Index_Search_Shipyard_Province');
	var shipyard_city=$('#Index_Search_Shipyard_City');
	var shipyard_shipType=$('#Index_Search_Shipyard_ShipType');
	var shipyard_reset=$('#Index_Search_Shipyard_Reset');
	var shipyard_button=$('#Index_Search_Shipyard_Button');	
	
	shipyard_reset.click(function()
	{
		shipyard_province.val('');
		shipyard_city.val('');
		shipyard_shipType.val('');
		return false;
	});
	
	shipyard_button.click(function()
	{
		if(shipyard_province.val()=='-1'&&shipyard_city.val()=='-1'&&shipyard_shipType.val()=='-1')
		{
			shipyard_province.focus();
			return false;
		}
		
		var location='/exec.php?action=shipyard_account_list&type=search';
		{
			if(shipyard_province.val()!=''){
				location=location+'&province='+encodeURI(shipyard_province.val());
			}		
			
			if(shipyard_city.val()!=''){
				location=location+'&city='+encodeURI(shipyard_city.val());
			}		
			
			if(shipyard_shipType.val()!=''){
				location=location+'&category='+encodeURI(shipyard_shipType.val());
			}					
		}		
		window.location=location;
		return false;
	});
	
	/**
	* 杂志订阅
	*/		
	var magazine_companyName=$('#Index_Magazine_CompanyName');
	var magazine_linkman=$('#Index_Magazine_Linkman');
	var magazine_phoneNumber=$('#Index_Magazine_PhoneNumber');
	var magazine_email=$('#Index_Magazine_Email');
	var magazine_postcode=$('#Index_Magazine_Postcode');
	var magazine_address=$('#Index_Magazine_Address');
	var magazine_submit=$('#Index_Magazine_Submit');
	var magazine_reset=$('#Index_Magazine_Reset');	
	var magazine_panel=$('#Index_Magazine_Panel');	
	
	magazine_reset.click(function()
	{
		magazine_companyName.val('');
		magazine_linkman.val('');
		magazine_phoneNumber.val('');
		magazine_email.val('');
		magazine_postcode.val('');
		magazine_address.val('');
		return false;		
	});
	
	magazine_submit.click(function()
	{
		if(magazine_companyName.val()=='')
		{
			magazine_companyName.focus();
			return false;
		}
		
		if(magazine_linkman.val()=='')
		{
			magazine_linkman.focus();
			return false;
		}
		
		if(magazine_phoneNumber.val()=='')
		{
			magazine_phoneNumber.focus();
			return false;
		}
		
		if(magazine_email.val()=='')
		{
			magazine_email.focus();
			return false;
		}
		
		if(magazine_postcode.val()=='')
		{
			magazine_postcode.focus();
			return false;
		}
		
		if(magazine_address.val()=='')
		{
			magazine_address.focus();
			return false;
		}		
		
		$(this).css('disabled',true);
		
		var data=
		{
			'CompanyName':magazine_companyName.val(),
			'Linkman':magazine_linkman.val(),
			'PhoneNumber':magazine_phoneNumber.val(),
			'Email':magazine_email.val(),
			'Postcode':magazine_postcode.val(),
			'Address':magazine_address.val()
		};
		
		$.post('/exec.php?action=magazine_index',data,function($data)
		{
			magazine_companyName.val('');
			magazine_linkman.val('');
			magazine_phoneNumber.val('');
			magazine_email.val('');
			magazine_postcode.val('');
			magazine_address.val('');			
			
			magazine_panel.text('订阅成功');
			magazine_panel.attr('disabled',false);
		});
	});
});
















